home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP12.ZIP / PATRON / ICLISITE.CPP < prev    next >
C/C++ Source or Header  |  1993-07-19  |  6KB  |  253 lines

  1. /*
  2.  * ICLISITE.CPP
  3.  *
  4.  * Implementation of the IOleClientSite interface for Patron's tenants.
  5.  *
  6.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Software Design Engineer
  9.  * Microsoft Systems Developer Relations
  10.  *
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "patron.h"
  17.  
  18.  
  19. /*
  20.  * CImpIOleClientSite::CImpIOleClientSite
  21.  * CImpIOleClientSite::~CImpIOleClientSite
  22.  *
  23.  * Parameters (Constructor):
  24.  *  pTenant         LPTENANT of the tenant we're in.
  25.  *  punkOuter       LPUNKNOWN to which we delegate.
  26.  */
  27.  
  28. CImpIOleClientSite::CImpIOleClientSite(LPTENANT pTenant, LPUNKNOWN punkOuter)
  29.     {
  30.     m_cRef=0;
  31.     m_pTen=pTenant;
  32.     m_punkOuter=punkOuter;
  33.     return;
  34.     }
  35.  
  36. CImpIOleClientSite::~CImpIOleClientSite(void)
  37.     {
  38.     return;
  39.     }
  40.  
  41.  
  42.  
  43.  
  44. /*
  45.  * CImpIOleClientSite::QueryInterface
  46.  * CImpIOleClientSite::AddRef
  47.  * CImpIOleClientSite::Release
  48.  *
  49.  * Purpose:
  50.  *  IUnknown members for CImpIOleClientSite object.
  51.  */
  52.  
  53. STDMETHODIMP CImpIOleClientSite::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  54.     {
  55.     return m_punkOuter->QueryInterface(riid, ppv);
  56.     }
  57.  
  58.  
  59. STDMETHODIMP_(ULONG) CImpIOleClientSite::AddRef(void)
  60.     {
  61.     ++m_cRef;
  62.     return m_punkOuter->AddRef();
  63.     }
  64.  
  65. STDMETHODIMP_(ULONG) CImpIOleClientSite::Release(void)
  66.     {
  67.     --m_cRef;
  68.     return m_punkOuter->Release();
  69.     }
  70.  
  71.  
  72.  
  73.  
  74. /*
  75.  * CImpIOleClientSite::SaveObject
  76.  *
  77.  * Purpose:
  78.  *  Requests that the container call OleSave for the object that lives
  79.  *  here.  Typically this happens on server shutdown.
  80.  *
  81.  * Parameters:
  82.  *  None
  83.  *
  84.  * Return Value:
  85.  *  HRESULT         Standard.
  86.  */
  87.  
  88. STDMETHODIMP CImpIOleClientSite::SaveObject(void)
  89.     {
  90.     //Since we're already set up with the tenant to save, this is trivial.
  91.     m_pTen->Update();
  92.     return NOERROR;
  93.     }
  94.  
  95.  
  96.  
  97.  
  98.  
  99. /*
  100.  * CImpIOleClientSite::GetMoniker
  101.  *
  102.  * Purpose:
  103.  *  Retrieves the moniker for the site in which this object lives,
  104.  *  either the moniker relative to the container or the full moniker.
  105.  *
  106.  * Parameters:
  107.  *  dwAssign        DWORD specifying that the object wants moniker
  108.  *                  assignment.  Yeah.  Right.  Got any bridges to sell?
  109.  *  dwWhich         DWORD identifying which moniker the object wants,
  110.  *                  either the container's moniker, the moniker relative
  111.  *                  to this client site, or the full moniker.
  112.  *
  113.  * Return Value:
  114.  *  HRESULT         Standard.
  115.  */
  116.  
  117. STDMETHODIMP CImpIOleClientSite::GetMoniker(DWORD dwAssign, DWORD dwWhich
  118.     , LPMONIKER FAR *ppmk)
  119.     {
  120.     *ppmk=NULL;
  121.  
  122.     //CHAPTER12MOD
  123.     /*
  124.      * To support linking as a container we at least have to implement
  125.      * this for OLEWHICKMK_CONTAINER but not for any others.  This allows
  126.      * OLE to update absolute monikers when it has to use the relative
  127.      * moniker to locate a link source.
  128.      */
  129.  
  130.     switch (dwWhich)
  131.         {
  132.         case OLEWHICHMK_CONTAINER:
  133.             //This is just the file we're living in.
  134.             if (NULL!=m_pTen->m_pmkFile)
  135.                 *ppmk=m_pTen->m_pmkFile;
  136.  
  137.             break;
  138.         }
  139.  
  140.     if (NULL==*ppmk)
  141.         return ResultFromScode(E_FAIL);
  142.  
  143.     (*ppmk)->AddRef();
  144.     return NOERROR;
  145.     //End CHAPTER12MOD
  146.     }
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. /*
  154.  * CImpIOleClientSite::GetContainer
  155.  *
  156.  * Purpose:
  157.  *  Returns a pointer to the document's IOleContainer interface.
  158.  *
  159.  * Parameters:
  160.  *  ppContainer     LPOLECONTAINER FAR * in which to return the interface.
  161.  *
  162.  * Return Value:
  163.  *  HRESULT         Standard.
  164.  */
  165.  
  166. STDMETHODIMP CImpIOleClientSite::GetContainer(LPOLECONTAINER FAR* ppContainer)
  167.     {
  168.     //No implementation necessary unless you allow linking to embeddings.
  169.     *ppContainer=NULL;
  170.     return ResultFromScode(E_NOTIMPL);
  171.     }
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. /*
  179.  * CImpIOleClientSite::ShowObject
  180.  *
  181.  * Purpose:
  182.  *  Tells the container to bring the object fully into view as much
  183.  *  as possible, that is, scroll the document.
  184.  *
  185.  * Parameters:
  186.  *  None
  187.  *
  188.  * Return Value:
  189.  *  HRESULT         Standard.
  190.  */
  191.  
  192. STDMETHODIMP CImpIOleClientSite::ShowObject(void)
  193.     {
  194.     /*
  195.      * We let the tenant do this, since it can access the current
  196.      * scroll position as a friend of CPages whereas we cannot.
  197.      */
  198.     m_pTen->ShowYourself();
  199.     return NOERROR;
  200.     }
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207. /*
  208.  * CImpIOleClientSite::OnShowWindow
  209.  *
  210.  * Purpose:
  211.  *  Informs the container if the object is showing itself or
  212.  *  hiding itself.  This is done only in the opening mode and allows
  213.  *  the container to know when to shade or unshade the object.
  214.  *
  215.  * Parameters:
  216.  *  fShow           BOOL indiciating that the object is being shown
  217.  *                  (TRUE) or hidden (FALSE).
  218.  * Return Value:
  219.  *  HRESULT         Standard.
  220.  */
  221.  
  222. STDMETHODIMP CImpIOleClientSite::OnShowWindow(BOOL fShow)
  223.     {
  224.     //All we have to do is tell the tenant of the open state change.
  225.     m_pTen->ShowAsOpen(fShow);
  226.     return NOERROR;
  227.     }
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234. /*
  235.  * CImpIOleClientSite::RequestNewObjectLayout
  236.  *
  237.  * Purpose:
  238.  *  Called when the object needs more room in the container and applies
  239.  *  only to extended layout negotiation not supported in OLE 2.0.
  240.  *
  241.  * Parameters:
  242.  *  None
  243.  *
  244.  * Return Value:
  245.  *  HRESULT         Standard.
  246.  */
  247.  
  248. STDMETHODIMP CImpIOleClientSite::RequestNewObjectLayout(void)
  249.     {
  250.     //Nothing to do since this is not supported in OLE 2.0.
  251.     return ResultFromScode(E_NOTIMPL);
  252.     }
  253.